﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using BCDto.Common.Business.WebsiteBusinessIntroduction;
using BCTMSRESTful.Configs;
using BCService.Utils;
using BCService.Common.Business.WebsiteBusinessIntroduction;
using System.Net;

namespace BCTMSRESTful.Controllers.Management.Common.Business
{
    /// <summary>
    /// 官网业务简介
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class WebsiteBusinessIntroductionController : ManagementBaseController
    {
        private readonly IWebsiteBusinessIntroductionService websiteBusinessIntroductionService;

        public WebsiteBusinessIntroductionController(IWebsiteBusinessIntroductionService websiteBusinessIntroductionService)
        {
            this.websiteBusinessIntroductionService = websiteBusinessIntroductionService;
        }

        #region 添加官网业务简介
        /// <summary>
        ///  添加官网业务简介
        /// </summary>
        /// <param name="requestDto">官网业务简介信息</param>
        /// <response code="201">添加官网业务简介成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加官网业务简介")]
        [ProducesResponseType(typeof(WebsiteBusinessIntroductionDto), 201)]
        public IActionResult Post(
            [FromBody]WebsiteBusinessIntroductionRequestDto requestDto)
        {
            var result = this.websiteBusinessIntroductionService.Add(requestDto,this.Admin);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
        #endregion

        #region 修改官网业务简介
        /// <summary>
        ///  修改官网业务简介
        /// </summary>
        /// <param name="websiteBusinessIntroductionId">官网业务简介Id</param>
        /// <param name="requestDto">官网业务简介信息</param>
        /// <response code="200">修改官网业务简介成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("{website_business_interdaction_id}")]
        [Log("修改官网业务简介")]
        [ProducesResponseType(typeof(WebsiteBusinessIntroductionDto), 200)]
        public IActionResult Put([FromRoute(Name = "website_business_interdaction_id")]int websiteBusinessIntroductionId, [FromBody]WebsiteBusinessIntroductionRequestDto requestDto)
        {
            WebsiteBusinessIntroductionPutDto putDto = requestDto.As<WebsiteBusinessIntroductionPutDto>();
            putDto.WebsiteBusinessIntroductionId = websiteBusinessIntroductionId;
            return StatusCode((int)HttpStatusCode.OK, this.websiteBusinessIntroductionService.Update(putDto,this.Admin));
        }
        #endregion

        #region 删除官网业务简介
        /// <summary>
        ///  删除官网业务简介
        /// </summary>
        /// <param name="websiteBusinessIntroductionId">官网业务简介Id</param>
        /// <response code="204">删除官网业务简介成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpDelete("{website_business_interdaction_id}")]
        [Log("删除官网业务简介")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "website_business_interdaction_id")]int websiteBusinessIntroductionId)
        {
            this.websiteBusinessIntroductionService.Delete(websiteBusinessIntroductionId);
            return StatusCode((int)HttpStatusCode.NoContent);
        }
        #endregion

        #region 获取官网业务简介
        /// <summary>
        ///  获取官网业务简介
        /// </summary>
        /// <param name="websiteBusinessIntroductionId">官网业务简介Id</param>
        /// <response code="200">获取官网业务简介</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("{website_business_interdaction_id}")]
        [ProducesResponseType(typeof(WebsiteBusinessIntroductionDto), 200)]
        public IActionResult Get([FromRoute(Name = "website_business_interdaction_id")]int websiteBusinessIntroductionId)
        {
            return StatusCode((int)HttpStatusCode.OK, this.websiteBusinessIntroductionService.Get(websiteBusinessIntroductionId));
        }
        #endregion

        #region 获取官网业务简介列表
        /// <summary>
        ///  获取官网业务简介列表
        /// </summary>
        /// <param name="businessCategoryId">业务分类Id</param>
        /// <response code="200">获取官网业务简介列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(WebsiteBusinessIntroductionDto), 200)]
        public IActionResult Get([FromQuery(Name = "website_business_category_id")]int? businessCategoryId)
        {
            return StatusCode((int)HttpStatusCode.OK, this.websiteBusinessIntroductionService.GetList(businessCategoryId));
        }
        #endregion

        #region 获取官网业务简介（分页）
        /// <summary>
        ///  获取官网业务简介（分页）
        /// </summary>
        /// <param name="businessCategoryId">业务分类Id</param>
        /// <param name="tagcode">业务标记码</param>
        /// <param name="itemName">简介项</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="index">当前页码</param>
        /// <param name="size">当前页大小</param>
        /// <response code="200">获取官网业务简介（分页）</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WebsiteBusinessIntroductionDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "website_business_category_id")]int? businessCategoryId,
            [FromQuery(Name = "website_business_tagcode")]string tagcode,
            [FromQuery(Name = "item_name")]string itemName,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            [FromQuery(Name = "sort_name")]string sortName,
            [FromQuery(Name = "ascending")]bool? ascending,
            [FromQuery(Name = "index")]int index = 1,
            [FromQuery(Name = "size")]int size = 10)
        {
            return StatusCode((int)HttpStatusCode.OK, this.websiteBusinessIntroductionService.Query(tagcode,businessCategoryId, itemName,start, end, sortName, ascending, index, size));
        }
        #endregion

        #region 启用/禁用官网业务简介
        /// <summary>
        ///  启用/禁用官网业务简介
        /// </summary>
        /// <param name="websiteBusinessIntroductionId">官网业务简介Id</param>
        /// <param name="enabled">是否启用</param>
        /// <response code="204">启用/禁用官网业务简介成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("[action]/{website_business_introduction_id}/{enabled}")]
        [Log("启用/禁用官网业务简介")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Enabled([FromRoute(Name = "website_business_introduction_id")]int websiteBusinessIntroductionId,
            [FromRoute(Name = "enabled")]bool enabled)
        {
            if (enabled)
            {
                this.websiteBusinessIntroductionService.Enabled(websiteBusinessIntroductionId);
                return StatusCode((int)HttpStatusCode.NoContent);
            }
            else
            {
                this.websiteBusinessIntroductionService.Disabled(websiteBusinessIntroductionId);
                return StatusCode((int)HttpStatusCode.NoContent);
            }
        }
        #endregion
    }
}